package com.shengqiang.cloud.ups.controller;

import com.shengqiang.cloud.ups.common.model.JsonResult;
import com.shengqiang.cloud.ups.dao.modal.UpmsRolePermission;
import com.shengqiang.cloud.ups.service.UpmsRolePermissionWebService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/1/15.
 */
@Controller
@RequestMapping(value = "permission")
public class PermissionController {

    @Autowired
    private UpmsRolePermissionWebService rolePermissionWebService;

    @RequiresPermissions(value = "upms:users:role:assPermissions")
    @ResponseBody
    @RequestMapping(value = "assign",method = {RequestMethod.POST,RequestMethod.GET})
    public JsonResult assignPermission(@RequestBody Map<String,Object> params){
        return rolePermissionWebService.assginRolePermission(params);
    }

    @ResponseBody
    @RequestMapping(value = "selectRolePermission",method = {RequestMethod.GET,RequestMethod.POST})
    public JsonResult<List<UpmsRolePermission>> selectRolePermission(@RequestParam Map<String,Object> params){
        return rolePermissionWebService.selectRolePermissions(params);
    }
}
